const digits:array[1..36] of char=('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
function fractodec(p:longint; n:string):string;
var index:int64; current,step:extended; i,j:integer;
begin
step:=1/p;
current:=0;
for i:=1 to length(n) do begin
  for j:=1 to 36 do if digits[j]=n[i] then index:=j;
  current:=current+step*(index-1);
  step:=step/p;
end;
result:=floattostr(current);
end;